/*
  Copyright (C) 2009, Bioingenium Research Group
  http://www.bioingenium.unal.edu.co
  Author: Alexander Pinzon Fernandez

  JNukak3D is free software; you can redistribute it and/or modify it under
  the terms of the GNU General Public License as published by the Free
  Software Foundation; either version 2 of the License, or (at your
  option) any later version.

  JNukak3D is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
  License for more details.

  You should have received a copy of the GNU General Public License
  along with JNukak3D; if not, write to the Free Software Foundation, Inc.,
  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA,
  or see http://www.gnu.org/copyleft/gpl.html
*/

package edu.co.unal.bioing.jnukak3d.plugin;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Alexander Pinzon Fernandez
 */
public class nkKernel {
    private Map<String, nkPlugin> m_LoadedPlugins;
    private nkDockServer m_DockServer;
    private static nkKernel INSTANCE = null;

    private nkKernel(){
    }

    public nkDockServer getDockServer(){
        if(m_DockServer == null)
            m_DockServer = new nkDockServer();
        return m_DockServer;
    }
    
    public void loadPlugin(String fileName, nkPlugin plugin){
        if(m_LoadedPlugins==null)
            m_LoadedPlugins = new HashMap<String, nkPlugin>();
        if(m_LoadedPlugins.containsKey(fileName) == false){
            m_LoadedPlugins.put(fileName, plugin);
            plugin.registerPlugin(this);
        }
    }

    private synchronized static void createInstance() {
        if (INSTANCE == null) {
            INSTANCE = new nkKernel();
        }
    }

    public static nkKernel getInstance() {
        if (INSTANCE == null) createInstance();
        return INSTANCE;
    }

    
    
}
